import pymysql


def update(sql, param):
    con = pymysql.connect(host="localhost", user="root", password="root", database="finance")
    cur = con.cursor()
    cur.execute(sql, param)
    con.commit()
    cur.close()
    con.close()
    return 0


def select(sql, param):
    con = pymysql.connect(host="localhost", user="root", password="root", database="finance")
    cur = con.cursor()
    cur.execute(sql, param)
    data = cur.fetchall()
    con.commit()
    cur.close()
    con.close()
    return data
